home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SPACE 2
/
SPACE - Library 2 - Volume 1.iso
/
music
/
213
/
comm
/
itoa.c
< prev
next >
Wrap
Text File
|
1988-01-13
|
406b
|
25 lines
char *itoa(num)
unsigned int num;
{
long digits[6]={1,10,100,1000,10000,100000};
static char str[10];
int max,i;
if (num<2)
{
max=1;
str[0]='0';
}
else
for (max=0;(max<6 && (long) num>digits[max]);str[max++]='0');
str[max]='\0';
if (num>0)
for (i=max;i>=0;--i)
while ((long) num-digits[i]>=0)
{
str[max-1-i]++;
num-=digits[i];
};
return(str);
}